var e = require("../../../public/pages/signin-page/checkIfNeedSignin"), i = function(e) {
    return e && e.__esModule ? e : {
        default: e
    };
}(require("../../../utils/api2"));

Page({
    data: {
        avatar: "",
        name: "",
        needVerifyMobile: !1
    },
    onLoad: function() {
        var e = this, i = getApp().globalData, t = i.tokens, r = i.card;
        this.setData({
            name: r.realname || t.realname,
            avatar: r.avatar || t.avatar
        }), this.getProviderInfo(), this.$addListener("update.count", function(i) {
            e.setData({
                "provider.nums": i
            });
        }), this.$addListener("update.provider", function(i) {
            var t = i.id, r = i.level;
            e.setData({
                "provider.id": t,
                "provider.level": r,
                "provider.authstatus": 2
            });
        }), this.checkIfNeedVerifyMobile();
    },
    checkIfNeedVerifyMobile: function() {
        1 != +getApp().globalData.tokens.isverifymobile && this.setData({
            needVerifyMobile: !0
        });
    },
    verifySuccess: function() {
        this.setData({
            needVerifyMobile: !1
        });
    },
    getProviderInfo: function() {
        var e = this;
        return i.default.site.agent.account({
            desc: "加载中"
        }).then(function(i) {
            e.setData({
                provider: i
            });
        });
    },
    bindMobile: function() {
        this.setData({
            authMobileShow: !0
        });
    },
    refresh: function() {
        this.getProviderInfo().then(function() {
            wx.showToast({
                title: "更新成功"
            });
        });
    },
    orderlist: function() {
        (0, e.askForSignin)() || this.$route("/pages/profile/orderlist/orderlist");
    },
    grouponlist: function() {
        (0, e.askForSignin)() || this.$route("/pages/profile/grouponlist/grouponlist");
    },
    reservationlist: function() {
        (0, e.askForSignin)() || this.$route("/pages/profile/reservationlist/reservationlist");
    },
    messagelist: function() {
        (0, e.askForSignin)() || this.$route("/pages/profile/messagelist/messagelist");
    },
    versionlist: function() {
        this.$route("/pages/profile/versionlist/versionlist");
    },
    redirectToMarket: function() {
        if (!(0, e.askForSignin)()) {
            var i = this.data.provider.id;
            i ? this.$route("/pages/provider/index/index?id=" + i) : wx.navigateToMiniProgram({
                appId: "wxecc63b3a901f879c"
            });
        }
    }
});